home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Apple / Apple II TNs(Text).cpt / Apple II TNs(Text) / IIGS / TN.IIGS.049 < prev    next >
Encoding:
Text File  |  1989-11-15  |  6.0 KB  |  129 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. Apple IIGS
  7. #49:    Rebooting (Really)
  8.  
  9. Revised by:    Matt Deatherage                                   January 1989
  10. Written by:    Matt Deatherage & Jim Merritt                    November 1988
  11.  
  12. This Technical Note discusses rebooting the Apple IIGS from software.
  13. Changed since November 1988:  Corrected two assembly-language 
  14. instructions in the FROMNATV routine in the example code.
  15. _____________________________________________________________________________
  16.  
  17. In days gone by, many Apple II applications had a Quit menu option.  
  18. Unfortunately, a large number of these simply rebooted the machine.  Today, 
  19. this is far from desirable.  Even with the advantages of GS/OS-reduced booting 
  20. time (around 34 seconds with an Apple 3.5 Drive), waiting for the operating 
  21. system to reload, as well as wiping out any ongoing tasks by desk accessories 
  22. (such as an alarm clock) makes the standard ProDOS 8 or GS/OS QUIT call much 
  23. more attractive.
  24.  
  25. However, there are still instances where an application may wish to require 
  26. the user to reboot.  A common example might be a game.  The game might use 
  27. GS/OS in a completely standard way, but if you QUIT from the program GS/OS 
  28. booted into, you will be returned to the same program.  Since most 
  29. applications will boot into the Finder, this is not a widespread problem.  
  30. However, the Finder must also provide the reboot option, and alternate program 
  31. selector applications may wish to provide this functionality as well.
  32.  
  33.  
  34. The Easy Way
  35.  
  36. GS/OS provides a mechanism for rebooting with the OSShutdown call.  This call, 
  37. documented in GS/OS Reference, Volume 1, will either reboot the system (after 
  38. first shutting down all loaded and generated drivers and closing all open 
  39. sessions) or will shut down everything and present a dialog box which states, 
  40. "You may now power down your Apple IIGS safely."  A Restart button is provided 
  41. which allows the user to reboot without pressing Control-Open Apple-Reset .
  42.  
  43. Note:    When using System Disk 4.0, if the Window Manager is active 
  44. when you issue the OSShutdown call, there must be at least one 
  45. open window; it need not be visible, but it must be open.  This 
  46. will be fixed in the next revision of GS/OS.
  47.  
  48. The OSShutdown call also provides a way to resize the internal RAM disk (named 
  49. /RAM5 by default).  Most programs have absolutely no need to use this 
  50. mechanism, and should avoid it whenever possible.  A notable exception would 
  51. be a third-party RAM disk utility which uses a battery backup, which may need 
  52. to make changes which require resizing the RAM disk.  Of course, such a 
  53. utility should ask the user to ensure that erasing the RAM disk content is 
  54. acceptable.  Resizing the RAM disk is only possible when using the OSShutdown 
  55. call; any other method you may be using to accomplish this function from 
  56. software will break in the future.
  57.  
  58.  
  59. If you are using GS/OS, you should always use OSShutdown. You must not reboot 
  60. the system in any other fashion.  The OSShutdown mechanism provides a 
  61. convenient and supported way to restart or shut down the system.  Doing it 
  62. another way can easily cause a loss of data.
  63.  
  64.  
  65. The Hard Way
  66.  
  67. Programs not using GS/OS have a little more work to do.  The supported non-
  68. GS/OS method of rebooting is similar to the method used on 8-bit machines:  
  69. change the value of POWERUP ($00/03F4) and do a long jump to RESET ($FA62).  
  70. However, there are a few catches:
  71.  
  72. 1.    The jump must be made in emulation mode.
  73. 2.    Interrupts must be disabled.
  74. 3.    The data bank register must be set to zero.
  75. 4.    The direct page must be zero.
  76. 5.    ROM firmware must be visible in the memory map.
  77. 6.    Internal interrupt sources (such as the ones for AppleTalk) must be 
  78.       shut down.
  79.  
  80. Simply disabling interrupts without shutting down AppleTalk interrupt sources 
  81. inside the system will cause the system to hang when the jump to RESET is 
  82. made.  Turning off these internal interrupt sources is accomplished by 
  83. changing softswitch values at $C039 (SCCAREG), $C041 (INTEN), and $C047 
  84. (CLRVBLINT).
  85.  
  86. The following code example demonstrates the correct method:
  87.  
  88. POWRUP       equ    $0003F4    ;the power-up byte in bank zero
  89. STATEREG     equ    $C068      ;ROM/RAM state register
  90. CLRVBLINT    equ    $C047      ;clear VBL interrupt flags register
  91. INTEN        equ    $C041      ;interrupt enable register
  92. SCCAREG      equ    $C039      ;SCC register
  93. RESET        equ    $00FA62    ;ROM reset entry point
  94. ;
  95. FROMNATV     anop              ;enter here from native mode
  96.              sei               ;disable interrupts
  97.              pea    0
  98.              pea    0          ;push four zero bytes on the stack
  99.              plb               ;pull data bank register
  100.              plb               ;(twice to balance the stack)
  101.              pld               ;pull 16-bit data bank register
  102.              sec    
  103.              xce               ;go into emulation mode
  104.              longa    off
  105.              longi    off
  106. FROMEMUL     anop              ;enter here from emulation mode
  107.              sei               ;disable interrupts for people entering here
  108.              dec    POWRUP     ;invalidate the power up byte
  109.              lda    #$0C       ;ROM parameters
  110.              sta    STATEREG   ;swap in the ROM and everything else out
  111.              stz    CLRVBLINT  ;clear VBL interrupts
  112.              stz    INTEN      ;turn off internal interrupt sources
  113.              lda    #$09
  114.              sta    SCCAREG    ;shut down SCC interrupt sources
  115.              lda    #$C0
  116.              sta    SCCAREG
  117.              jml    RESET      ;and off we go into the wild blue yonder
  118.  
  119. These methods of restarting the system are presented for those applications 
  120. that absolutely must do so.  Rebooting is not a suggested way of ending an 
  121. application and the techniques described in this Note should be used with 
  122. extreme caution.
  123.  
  124.  
  125. Further Reference
  126. _____________________________________________________________________________
  127. o    Apple IIGS Firmware Reference
  128. o    GS/OS Reference, Volume 1
  129.